
//判断是android还是IOS系统
function checkOS() {
    var ua = navigator.userAgent.toLowerCase();
    if (/iphone|ipad|ipod/.test(ua)) {
        return "IOS";
    } else if (/android/.test(ua)) {
        return "Android";
    }
}
//o家APP初始ios 注册
function setupWebViewJavascriptBridge(callback) {
    if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
    if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
    window.WVJBCallbacks = [callback];
    var WVJBIframe = document.createElement('iframe');
    WVJBIframe.style.display = 'none';
    WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
    document.documentElement.appendChild(WVJBIframe);
    setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
}
//ios调用
setupWebViewJavascriptBridge(function(bridge) {
    bridge.registerHandler('testJSFunction', function(data, responseCallback) {
        responseCallback('js执行过了');
    })
})

function returnBack(){
    //调用原生的返回上一页方法
    if(checkOS()=="Android")
    {
        maojia.mjGoBack();
    } else{
        setupWebViewJavascriptBridge(function(bridge) {
            bridge.callHandler('mjGoBack', function(response) {
            })
        })
    }
}
function getUrlParams(){
    var url = location.search;
    var bagin = url.indexOf("?");
    var backurl = url.substring(bagin+9,url.length);
    return backurl;
}

function SuccessReturn(){
    if(checkOS()=="Android")
    {
        maojia.mjGoBack();
    } else{
        setupWebViewJavascriptBridge(function(bridge) {
            bridge.callHandler('mjGoBack', function(response) {
            })
        })
    }
}

function ErrorReturn(){
    //调用原生的返回上一页方法
    if(checkOS()=="Android")
    {
        maojia.mjGoBack();
    } else{
        setupWebViewJavascriptBridge(function(bridge) {
            bridge.callHandler('mjGoBack', function(response) {
            })
        })
    }
}


